
#ifndef GRAPHICSOBJECT_H
#define GRAPHICSOBJECT_H

#include <QGraphicsObject>
#include <QVarLengthArray>
#include "common.h"
#include "ShowParam.h"

class GraphicsScene;
class Tag;
class Resizer;

class GraphicsObject : public QGraphicsObject
{
protected:
    typedef QList< Tag* >::iterator TagIter;
    enum RPType { rpShow, rpHide, rpUpdate, rpNone };
    QColor clr;
    GraphicsScene * scene;
    QVarLengthArray< Resizer*, dotCount > resizingPoints;

    QList< Tag* > tagList;

    QRectF rect;
    bool canResize;

    void ResizingPoints( const RPType t );

    bool _show;

public:
    explicit GraphicsObject( QGraphicsObject * Owner = 0);

    GraphicsScene * GetScene() { return scene; }
    void SetScene( GraphicsScene * s ) { if( s ) scene = s; }

    QColor GetColor() { return clr; }
    virtual void SetColor( QColor c ) { clr = c; }

    QRectF GetRect() const { return rect; }
    void Resize( QRectF newSize );

    void AddTag( Tag * t ) { tagList.append( t ); }
    void RmTag( Tag * t );

    QList< Tag* > * GetTagList() { return &tagList; }
    void RmAllTags();

    virtual void UpdateParamStr() = 0;

    void Show() { _show = true; }
    void Hide() { _show = false; }

    void Update() { update( rect ); }

};

#endif // GRAPHICSOBJECT_H
